package cn.edu.ctbu.test.controller;

import cn.edu.ctbu.test.domain.Sc;
import cn.edu.ctbu.test.service.ScService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class ScController {
    @Autowired
    ScService scService;

    @RequestMapping("/sc/sc")
    public String List(HttpServletRequest httprequest, Model model)
    {
        HttpSession session=httprequest.getSession();

        if(session.getAttribute("userid")==null){
            //未登录，需要登录
            return "redirect:index";
        }


        List<Sc> scs=scService.findAll();

        model.addAttribute("data",scs);

        return "sc/sc";
    }
}
